package com.spring.demo.controller;

import com.spring.demo.service.IDemoService;
import com.spring.mvcframework.annotations.Autowired;
import com.spring.mvcframework.annotations.Controller;
import com.spring.mvcframework.annotations.RequestMapping;
import com.spring.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    private IDemoService demoService;


    @Security(value = {"one"})
    @RequestMapping("/query1")
    public void queryOne(HttpServletResponse response, String username) throws Exception {
        response.getWriter().write(demoService.get(username));
    }

    @Security(value = {"two"})
    @RequestMapping("/query2")
    public void queryTwo(HttpServletResponse response, String username) throws Exception {
        response.getWriter().write(demoService.get(username));
    }

    @Security(value = {"three"})
    @RequestMapping("/query3")
    public void queryThree(HttpServletResponse response, String username) throws Exception {
        response.getWriter().write(demoService.get(username));
    }

    @Security(value = {"one", "two", "three"})
    @RequestMapping("/query")
    public void queryFour(HttpServletResponse response, String username) throws Exception {
        response.getWriter().write(demoService.get(username));
    }
}
